/* $RCSFile: RadExplorer.aspx.cs $
 * Apache license v2 2011 by Christian Surieux
 * $Source: ?/AddonNice/aspnet_client/FileExplorer/RadExplorer.aspx.cs $
 * $log$
 * Revision 20 2010/08/09 10:51:18  christian.surieux
 *   Added Log comment to all .aspx .ascx .master files
 * Revision 19 2010/08/09 09:43:43  christian.surieux
 *   Added Log to cs sources files
 * Revision 6 2010/08/06 19:56:24  christian.surieux
 *   Added Log to All cs files
 */

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

using AddonNice.UI;
using AddonNice.Settings;
using AddonNice.UI.WebControls;
using AddonNice.Security;
using AddonNice.Configuration;
using AddonNice.Diagnostics;
using AddonNice.Helpers;

using Telerik.Web.UI;

using Trace2    =   System.Diagnostics.Trace;
using Path2     =   AddonNice.Settings.Path;

namespace AddonNice.FileExplorer
{
    public partial class RadExplorer : StdAuxPage // could be derived from Page but we want to get the default site theme
    {
        // We do not want the default site masterPage
        public override bool SupportMasterPage
        {
            get
            {
                return false;
            }
        }
                
        
        protected void Page_Load(object sender, EventArgs e)
        {
	        if (PageTraceSwitch.Sw.TraceVerbose)
                Trace2.WriteLine("[V]RadExplorer Page_Load BEG.",PageTraceSwitch.Sw.Info);
            if ( !IsPostBack )
            {
            string senderId               =   Request.QueryString["senderTbId"];
            if ( !string.IsNullOrEmpty(senderId) )
                SenderTbID.Value   =   Page.Server.HtmlDecode(senderId);
            }
        }
 		override protected void OnInit(EventArgs e)
		{
	        if (PageTraceSwitch.Sw.TraceVerbose)
                Trace2.WriteLine("[V]RadExplorer OnInit BEG.",PageTraceSwitch.Sw.Info);
			InitializeComponent();	
			base.OnInit(e);
	        if (PageTraceSwitch.Sw.TraceVerbose)
                Trace2.WriteLine("[V]RadExplorer PreInit END.",PageTraceSwitch.Sw.Info);
		}

		private void InitializeComponent() 
		{    
			Load						+=	new System.EventHandler(Page_Load);
            string viewPath             =   Request.QueryString["ViewPath"];
            if ( string.IsNullOrEmpty(viewPath) )
                viewPath                =   portalSettings.PortalFullPath;
            else viewPath               =   Page.Server.HtmlDecode(viewPath);
	        if (PageTraceSwitch.Sw.TraceVerbose)
                Trace2.WriteLine(string.Format("[V]RadExplorer InitializeComponent viewPath: {0}.",viewPath),PageTraceSwitch.Sw.Info);
            FileExplorer1.Configuration.ViewPaths       =  new string[]{viewPath};
            string searchPat            =   Request.QueryString["searchPat"];
            if ( string.IsNullOrEmpty(searchPat) )
                searchPat               =   "*.*";
            else searchPat              =   Page.Server.HtmlDecode(searchPat);
	        if (PageTraceSwitch.Sw.TraceVerbose)
                Trace2.WriteLine(string.Format("[V]RadExplorer InitializeComponent searchPat: {0}.",searchPat),PageTraceSwitch.Sw.Info);
            string[] sp                 =   searchPat.Split(new char[]{','},StringSplitOptions.RemoveEmptyEntries);
            FileExplorer1.Configuration.SearchPatterns  =  sp;
            string selVal               =   Request.QueryString["Sel"];
            if ( !string.IsNullOrEmpty(selVal) )
                FileExplorer1.InitialPath   =   Page.Server.HtmlDecode(selVal);
 		}
   }
}
